using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Forum", "forumId", "Torch.WL.ConnectionString")]
    public class Tb_Forum : Info
    {
        #region SQL column name consts
        public const string SQLCOL_FORUMID = "forumId";
        public const string SQLCOL_FORUMPID = "forumPId";
        public const string SQLCOL_FORUMNAME = "forumName";
        public const string SQLCOL_ISLEAFNODE = "IsLeafNode";
        public const string SQLCOL_FORUMTYPE = "forumType";
        public const string SQLCOL_SORTINDEX = "SortIndex";
        public const string SQLCOL_PIDPATH = "PIdPath";
        public const string SQLCOL_SHOWDATE = "showDate";
        public const string SQLCOL_BEGINDATE = "BeginDate";
        public const string SQLCOL_ENDDATE = "EndDate";
        public const string SQLCOL_PLACE = "Place";
        public const string SQLCOL_FORUMTEACHER = "forumTeacher";
        public const string SQLCOL_FORUMTHEME = "forumTheme";
        public const string SQLCOL_MEMO = "Memo";
        public const string SQLCOL_MEMOIMG = "MemoImg";
        public const string SQLCOL_RACEZANZHU = "raceZanZhu";
        public const string SQLCOL_RACEPERSON = "racePerson";
        public const string SQLCOL_CREATETIME = "createTime";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Tb_Forum() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Tb_Forum(int forumId)
        {
            this.forumId = forumId;
        }
        #endregion

        public override void Init(DataRow row)
        {
            forumId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_FORUMID]);
            forumPId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_FORUMPID]);
            forumName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_FORUMNAME]);
            IsLeafNode = (bool)ObjectType.BooleanTypeHelper.Read(row[SQLCOL_ISLEAFNODE]);
            forumType = (byte)ObjectType.ByteTypeHelper.Read(row[SQLCOL_FORUMTYPE]);
            SortIndex = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SORTINDEX]);
            PIdPath = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PIDPATH]);
            showDate = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SHOWDATE]);
            BeginDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_BEGINDATE]);
            EndDate = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_ENDDATE]);
            Place = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PLACE]);
            forumTeacher = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_FORUMTEACHER]);
            forumTheme = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_FORUMTHEME]);
            Memo = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MEMO]);
            MemoImg = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MEMOIMG]);
            raceZanZhu = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_RACEZANZHU]);
            racePerson = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_RACEPERSON]);
            createTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_CREATETIME]);
        }

        #region Properties
        #region Property <int> forumId
        [Property("forumId", 4, SqlDbType.Int, true, true)]
        public int forumId
        {
            get { return _forumId; }
            set { _forumId = value; }
        }
        private int _forumId = int.MinValue;
        #endregion

        #region Property <int> forumPId
        [Property("forumPId", 4, SqlDbType.Int, false, false)]
        public int forumPId
        {
            get { return _forumPId; }
            set { _forumPId = value; }
        }
        private int _forumPId = int.MinValue;
        #endregion

        #region Property <string> forumName
        [Property("forumName", 100, SqlDbType.VarChar, false, false)]
        public string forumName
        {
            get { return _forumName; }
            set { _forumName = value; }
        }
        private string _forumName = null;
        #endregion

        #region Property <bool> IsLeafNode
        [Property("IsLeafNode", 1, SqlDbType.Bit, false, false)]
        public bool IsLeafNode
        {
            get { return _IsLeafNode; }
            set { _IsLeafNode = value; }
        }
        private bool _IsLeafNode = false;
        #endregion

        #region Property <byte> forumType
        [Property("forumType", 1, SqlDbType.TinyInt, false, false)]
        public byte forumType
        {
            get { return _forumType; }
            set { _forumType = value; }
        }
        private byte _forumType = byte.MinValue;
        #endregion

        #region Property <int> SortIndex
        [Property("SortIndex", 4, SqlDbType.Int, false, false)]
        public int SortIndex
        {
            get { return _SortIndex; }
            set { _SortIndex = value; }
        }
        private int _SortIndex = int.MinValue;
        #endregion

        #region Property <string> PIdPath
        [Property("PIdPath", 1000, SqlDbType.VarChar, false, false)]
        public string PIdPath
        {
            get { return _PIdPath; }
            set { _PIdPath = value; }
        }
        private string _PIdPath = null;
        #endregion

        #region Property <string> showDate
        [Property("showDate", 50, SqlDbType.VarChar, false, false)]
        public string showDate
        {
            get { return _showDate; }
            set { _showDate = value; }
        }
        private string _showDate = null;
        #endregion

        #region Property <DateTime> BeginDate
        [Property("BeginDate", 16, SqlDbType.DateTime, false, false)]
        public DateTime BeginDate
        {
            get { return _BeginDate; }
            set { _BeginDate = value; }
        }
        private DateTime _BeginDate = DateTime.MinValue;
        #endregion

        #region Property <DateTime> EndDate
        [Property("EndDate", 16, SqlDbType.DateTime, false, false)]
        public DateTime EndDate
        {
            get { return _EndDate; }
            set { _EndDate = value; }
        }
        private DateTime _EndDate = DateTime.MinValue;
        #endregion

        #region Property <string> Place
        [Property("Place", 50, SqlDbType.VarChar, false, false)]
        public string Place
        {
            get { return _Place; }
            set { _Place = value; }
        }
        private string _Place = null;
        #endregion

        #region Property <string> forumTeacher
        [Property("forumTeacher", 100, SqlDbType.VarChar, false, false)]
        public string forumTeacher
        {
            get { return _forumTeacher; }
            set { _forumTeacher = value; }
        }
        private string _forumTeacher = null;
        #endregion

        #region Property <string> forumTheme
        [Property("forumTheme", 200, SqlDbType.VarChar, false, false)]
        public string forumTheme
        {
            get { return _forumTheme; }
            set { _forumTheme = value; }
        }
        private string _forumTheme = null;
        #endregion

        #region Property <string> Memo
        [Property("Memo", 2147483647, SqlDbType.Text, false, false)]
        public string Memo
        {
            get { return _Memo; }
            set { _Memo = value; }
        }
        private string _Memo = null;
        #endregion

        #region Property <string> MemoImg
        [Property("MemoImg", 100, SqlDbType.VarChar, false, false)]
        public string MemoImg
        {
            get { return _MemoImg; }
            set { _MemoImg = value; }
        }
        private string _MemoImg = null;
        #endregion

        #region Property <string> raceZanZhu
        [Property("raceZanZhu", 500, SqlDbType.VarChar, false, false)]
        public string raceZanZhu
        {
            get { return _raceZanZhu; }
            set { _raceZanZhu = value; }
        }
        private string _raceZanZhu = null;
        #endregion

        #region Property <string> racePerson
        [Property("racePerson", 500, SqlDbType.VarChar, false, false)]
        public string racePerson
        {
            get { return _racePerson; }
            set { _racePerson = value; }
        }
        private string _racePerson = null;
        #endregion

        #region Property <DateTime> createTime
        [Property("createTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime createTime
        {
            get { return _createTime; }
            set { _createTime = value; }
        }
        private DateTime _createTime = DateTime.MinValue;
        #endregion
        #endregion


        public bool LoadByIdentity(int forumId)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(forumId));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
